// Ofri Keidar 302933981 group 05

package operator;

import controller.ClientController;
import controller.ConnectionManager;
import controller.ServerException;
import view.View;
import view.UserInterface;

/**
 * This class holds main function, where client's system is initialized and then starts running 
 */
public class OperateClient {

	private View clientManager; // object to manage client
	
	/**
	 * Allocates an object to operate the system.
	 * Uses the object to initialize the system and
	 * then to start system's running 
	 * @param args- none
	 */
	public static void main(String[] args) {
		
		// allocate a new operator for the system
		OperateClient operator;

		try {
			
			operator = new OperateClient();
			operator.start(); // run system
			
		} catch (ServerException e) {
			
			// display error message
			System.out.println(e.getMessage());
		}
	}
	
	/**
	 * Creates a new OperateSystem instance
	 * @throws ServerException if had problem connecting to server
	 */
	public OperateClient() throws ServerException {

		// create a controller
		ClientController controller = new ConnectionManager();

		// create an object to manage system
		clientManager = new UserInterface(controller);
	}
	
	/**
	 * Starts system's running using the system manager object
	 */
	private void start() {
		
		// start system's running
		clientManager.startRunning();
	}
}